package logic

import (
	"context"
	"work-safety/model/model"

	"work-safety/workrpc/internal/svc"
	"work-safety/workrpc/workrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddLogic {
	return &AddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AddLogic) Add(in *workrpc.AddRequest) (*workrpc.AddResponse, error) {
	// todo: add your logic here and delete this line

	shop := model.Shop{
		Phone:    in.Phone,
		Password: in.Password,
	}
	model.DB.Debug().Create(&shop)

	return &workrpc.AddResponse{
		ShopId: int64(shop.ID),
	}, nil
}
